package com.hjm.project.team.teamYl.controller;

import java.util.List;

import com.hjm.project.team.teamYl.domain.TeamYl;
import com.hjm.project.team.teamYl.service.ITeamYlService;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import com.hjm.framework.aspectj.lang.annotation.Log;
import com.hjm.framework.aspectj.lang.enums.BusinessType;
import com.hjm.framework.web.controller.BaseController;
import com.hjm.framework.web.domain.AjaxResult;
import com.hjm.common.utils.poi.ExcelUtil;
import com.hjm.framework.web.page.TableDataInfo;

import javax.annotation.Resource;

/**
 * 团长信息Controller
 * 
 * @author maker-platform
 * @date 2021-04-10
 */
@Controller
@RequestMapping("/team/teamYl")
public class TeamYlController extends BaseController
{
    private String prefix = "team/teamYl";

    @Resource
    private ITeamYlService teamYlService;


    @RequiresPermissions("team:team:view")
    @GetMapping()
    public String team()
    {
        return prefix + "/teamYl";
    }

    /**
     * 查询团长信息列表
     */
    @RequiresPermissions("team:team:list")
    @PostMapping("/list")
    @ResponseBody
    public TableDataInfo list(TeamYl teamYl)
    {
        startPage();
        List<TeamYl> list = teamYlService.selectTeamYlList(teamYl);
        return getDataTable(list);
    }

    /**
     * 导出团长信息列表
     */
    @RequiresPermissions("team:team:export")
    @Log(title = "团长信息", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    @ResponseBody
    public AjaxResult export(TeamYl teamYl)
    {
        List<TeamYl> list = teamYlService.selectTeamYlList(teamYl);
        ExcelUtil<TeamYl> util = new ExcelUtil<TeamYl>(TeamYl.class);
        return util.exportExcel(list, "team");
    }

    /**
     * 新增团长信息
     */
    @GetMapping("/add")
    public String add()
    {
        return prefix + "/add";
    }


    /**
     * 查询团长信息列表
     */
    @RequiresPermissions("team:team:list")
    @PostMapping("/selectTeamList")
    @ResponseBody
    public TableDataInfo selectTeamList(TeamYl teamYl)
    {
        startPage();
        List<TeamYl> list = teamYlService.selectTeamYlList(teamYl);
        return getDataTable(list);
    }



    /**
     * 新增保存团长信息
     */
    @RequiresPermissions("team:team:add")
    @Log(title = "团长信息", businessType = BusinessType.INSERT)
    @PostMapping("/add")
    @ResponseBody
    public AjaxResult addSave(TeamYl teamYl)
    {
        return toAjax(teamYlService.insertTeamYl(teamYl));
    }

    /**
     * 修改团长信息
     */
    @GetMapping("/edit/{teamYlId}")
    public String edit(@PathVariable("teamYlId") String teamYlId, ModelMap mmap)
    {
        TeamYl teamYl = teamYlService.selectTeamYlById(teamYlId);
        mmap.put("teamYl", teamYl);
        return prefix + "/edit";
    }

    /**
     * 修改保存团长信息
     */
    @RequiresPermissions("team:team:edit")
    @Log(title = "团长信息", businessType = BusinessType.UPDATE)
    @PostMapping("/edit")
    @ResponseBody
    public AjaxResult editSave(TeamYl teamYl)
    {
        return toAjax(teamYlService.updateTeamYl(teamYl));
    }

    /**
     * 删除团长信息
     */
    @RequiresPermissions("team:team:remove")
    @Log(title = "团长信息", businessType = BusinessType.DELETE)
    @PostMapping( "/remove")
    @ResponseBody
    public AjaxResult remove(String ids)
    {
        return toAjax(teamYlService.deleteTeamYlByIds(ids));
    }
}
